package cn.iocoder.yudao.module.book.controller.app.bookClassify;

import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
import cn.iocoder.yudao.module.book.controller.admin.classify.vo.ClassifyPageReqVO;
import cn.iocoder.yudao.module.book.controller.admin.classify.vo.ClassifyRespVO;
import cn.iocoder.yudao.module.book.controller.admin.classify.vo.ClassifySaveReqVO;
import cn.iocoder.yudao.module.book.controller.app.bookClassify.vo.AppClassifyRespVO;
import cn.iocoder.yudao.module.book.controller.app.bookcase.vo.AppBookshelfRespVO;
import cn.iocoder.yudao.module.book.controller.app.booksShell.vo.AppCollectionsRespVO;
import cn.iocoder.yudao.module.book.dal.dataobject.classify.ClassifyDO;
import cn.iocoder.yudao.module.book.service.bookshelf.BookshelfService;
import cn.iocoder.yudao.module.book.service.classify.ClassifyService;
import cn.iocoder.yudao.module.book.service.users.userDTOService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;

@Tag(name = "APP - 类别")
@RestController
@RequestMapping("/api/user/book")
@Validated
public class AppClassifyController {

    @Resource
    private ClassifyService classifyService;

    @Resource
    private userDTOService userService;

    @Resource
    private BookshelfService bookshelfService;


    @GetMapping("/categories")
    @Operation(summary = "获得中英文绘本集列表-一级分类")
    public CommonResult<List<ClassifyDO>> getBookCategories(@Valid @RequestParam("lang") Integer lang) {
//        System.out.println(userService.getCurrentUserId());
//        List<AppBookshelfRespVO> collection = bookshelfService.selectByUserId(userService.getCurrentUserId());
          List<ClassifyDO> collection = classifyService.selectAllCategories();
//    bookshelfService.selectAllCategories();

        System.out.println(collection);

//        System.out.println(collections);
//        collections.sort(Comparator.comparing(AppCollectionsRespVO::getCategoryId ));

        return CommonResult.success(collection);
    }

}